<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="股道" prop="trackName">
        <el-input v-model="queryParams.trackName" placeholder="请输入股道" clearable maxlength="10" style="width: 220px"
          show-word-limit @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="车列号" prop="carCode">
        <el-input v-model="queryParams.carCode" placeholder="请输入车列号" clearable maxlength="15" style="width: 220px"
          show-word-limit @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="作业类型" prop="type">
        <el-select v-model="queryParams.type">
          <el-option v-for="(item) in jobTypelists" :key="item.id" :label="item.name" :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <div class="searchReset">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </div>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <div :class="eleTabTop <= 85 ? 'eleTab' : ''" class="informationTab" ref="eleTab">
      <el-table v-loading="loading" :data="carList">
        <el-table-column label="序号" align="center" type="index" width="100" />
        <el-table-column label="股道" align="center" prop="track" min-width="200" :show-overflow-tooltip="true" />
        <el-table-column label="列位" align="center" prop="complete" min-width="200" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="车列号" align="center" prop="carcode" min-width="200" :show-overflow-tooltip="true" />
         <el-table-column label="作业类型" align="center" prop="jobtype" min-width="200" :show-overflow-tooltip="true" />
         <el-table-column label="班组名称" align="center" prop="teamname" min-width="200" :show-overflow-tooltip="true" />
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
  </div>
</template>

<script>
  import {
    noteam
  } from "@/api/urgencyRemovework";
  export default {
    name: "Unregist",
    data() {
      return {
        timers:null,
        jobTypelists: [{
            id: 1,
            name: '供电预检'
          },
          {
            id: 2,
            name: '断电作业'
          },
          {
            id: 3,
            name: '供电检修'
          }
        ],
        eleTabTop: 0, //表格容器eleTabTop距浏览器顶部距离
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 表格数据
        carList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          type: null,
          trackName: null,
          carCode: null
        },
      };
    },
    created() {
      this.getList();
      this.timers = setInterval(()=>{
          this.getList();
      },60000)
    },
    mounted() {
      // 滚动条的获取
      this.handleScrollx();
      window.addEventListener("scroll", this.handleScrollx, true);
    },
    activated() {
      //获取表格容器距页面头部的距离
      this.handleScrollx();
    },
    destroyed() {
      window.removeEventListener("scroll", this.handleScrollx, true);
       this.timers = null;
      clearInterval(this.timers);
    },
    methods: {
      //获取表格容器距页面头部的距离
      handleScrollx() {
        this.eleTabTop = this.$refs.eleTab.getBoundingClientRect().top;
      },
      /** 查询车辆信息列表 */
      getList() {
        this.loading = true;
        noteam(this.queryParams).then((response) => {
          this.carList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      }
    },
  };
</script>
<style scoped lang='scss'>
::v-deep .eleTab {
  .el-table__header-wrapper {
    position: fixed;
    z-index: 9;
    top: 115px;
    right: 20px;
    padding-left:239px;
  }
  .el-table__fixed-header-wrapper .fixed-width {
    position: fixed;
    width: 350px !important;
    top: 115px;
    height: 46px;
    right: 20px;
  }
  .el-table__body-wrapper {
    margin-top: 50px !important;
  }
  .el-table__fixed-body-wrapper {
    z-index: 2;
    top: 50px !important;
  }
  .el-table__fixed-right {
    // z-index: 10;
  }
}
</style>
